#include "../include/test.h"
#include <stdio.h>
#include <string.h>
	struct Node* searchNode(int file_descriptor_no){
		int i = file_descriptor_no , current_file_descriptor_no,temp,j;
		struct Node* traverse = vfs , *tempNode = vfs ;
		if(vfs->file_descriptor_no == file_descriptor_no)
			traverse = vfs;
		else{
		    //printf("header.fd[i].location_path = %s\n",header.fd[i].location_path);
			for(j = 2; j < strlen(header.fd[i].location_path);){
			    	tempNode = traverse->child; // TRAVERSE SHOULD ALWAYS POINT TO THE PARENT OF THE NODE TO BE ADDED . 
				current_file_descriptor_no = atoi(header.fd[i].location_path + j);
				temp = current_file_descriptor_no;
				//printf("current_file_descriptor_no = %d",current_file_descriptor_no);
				while(temp != 0){ //This increment in j accounts to the no of digits in the current file descriptor
					temp =temp/10;
					j++;
				}
				j++; //This increment in j accounts to the single character i.e filetype=directory

				if(tempNode->file_descriptor_no == current_file_descriptor_no){ //If the current node itself is the node we are searching for
					//printf("tempNode->file_descriptor_no (%d) == current_file_descriptor_no(%d)",tempNode->file_descriptor_no,current_file_descriptor_no);
					traverse = tempNode;
				}
				else{
				    while((tempNode->sibling != NULL) && (tempNode->file_descriptor_no < current_file_descriptor_no) ){
					    tempNode = tempNode->sibling;
					    if(tempNode->file_descriptor_no == current_file_descriptor_no){
						    traverse = tempNode;

					    }
					}
				}		
			}}
			//printf("file_descriptor_no  = %d, traverse->file_descriptor_no = %d\n",file_descriptor_no , traverse->file_descriptor_no);
		return traverse;
	}
